﻿using DevExpress.XtraGrid.Views.Grid;
using RecruitStudents.Client.BLL;
using RecruitStudents.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Consult
{
    public partial class ConsultForm_Type_List : BaseForm
    {
        ServiceConsult service = new ServiceConsult();
        public ConsultForm_Type_List()
        {
            InitializeComponent();
            BindList();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {

            ConsultForm_Type_Option option = new ConsultForm_Type_Option(string.Empty);
            if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                BindList();
            }
        }

        private void BindList()
        {
            DataTable dt = service.GetDicMsgTypeTable(txtName.Text);
           
            dataGridViewX1.DataSource = dt;
        }

        private void benQuery_Click(object sender, EventArgs e)
        {
            BindList();
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            if (gridView1.GetFocusedValue() != null)
            {
                GridView rows = sender as GridView;
                int[] inteurm = rows.GetSelectedRows();
                if (inteurm != null && inteurm.Length > 0)
                {
                    string SpecialityKindsNO = rows.Rows[inteurm[0]].DataRow["ID"].ToString();
                    ConsultForm_Type_Option option = new ConsultForm_Type_Option(SpecialityKindsNO);
                    if (option.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        BindList();
                    }
                }
            }
        }
    }
}
